package org.atlantis.uzw.utils;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class DaemonSharedExecutor {

	public static final ThreadFactory threadFactory = new ThreadFactory() {

		private ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory();

		@Override
		public Thread newThread(Runnable r) {
			Thread t = defaultThreadFactory.newThread(r);
			t.setDaemon(false);
			return t;
		}
	};

	public static ExecutorService executor = new ThreadPoolExecutor(8, 16, 16, TimeUnit.SECONDS,
			new ArrayBlockingQueue<Runnable>(1024), threadFactory);

	public static ScheduledExecutorService timer = Executors.newScheduledThreadPool(5, threadFactory);
}
